<template>
	<view class="p30">
		<view class="fw-w fs32 mb20">基本信息</view>
		<view class="radius20 bg-fff pl20 pr20 mb20">
			<u-form labelWidth="auto">
				<u-form-item label="团队头像" right-icon="arrow-right">
					<view class="flex row-right w-max">
						<z-imgs up max="1" size="120" @success="form.avatar=$event" :paths="data.avatar_path"
							:ids="data.avatar"></z-imgs>
							
					</view>
				</u-form-item>
				<u-form-item label="团队名称">
					<u-input type="text" v-model="form.name" placeholder="请输入团队名称" />
				</u-form-item>
				<u-form-item label="团队电话">
					<u-input type="number" v-model="form.mobile" maxlength="11" placeholder="请输入团队电话" />
				</u-form-item>
				<u-form-item label="展示城市">
					<u-input type="text" :modelValue="$user.city_name" disabled placeholder="默认展示认证时的省市，不能修改" />
				</u-form-item>
				<u-form-item label="详细地址">
					<u-input type="text" v-model="form.address" placeholder="请输入详细地址" />
				</u-form-item>
			</u-form>

		</view>
		<view class="fw-w fs32 mb20">详情介绍</view>
		<view class="bg-fff radius20 p20">
			<u-input type="textarea" height="270" v-model="form.introduce" placeholder="请输入详情介绍" :clearable="false" />
			<view class="w-max mt20">
				<z-imgs up @success="form.images=$event" :paths="data.images_path" :ids="data.images" max="9" />
			</view>
		</view>
		<view class="h120"></view>
		<view class="pf bottom0 left0 bg-fff w-max">
			<view class="flex">
				<view class="flex1 p20">
					<u-button type="warning" ripple @click="submit">提交</u-button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					id:'',
					avatar: '',
					name: '',
					mobile: '',
					// city_id: '',
					address: '',
					introduce: '',
					images: '',
				},
				data: ''
			};
		},
		onLoad(e) {
			if (e.agency_id) {
				this.getData()
				uni.setNavigationBarTitle({
					title: '编辑团队'
				})
			}
		},
		methods: {
			getData() {
				if (!this.$params.agency_id) return
				this.$request('/master/agency/agencyInfo', this.$params).then(res => {
					this.data = res.data
					Object.keys(this.form).map(key => {
						res.data[key] ? this.form[key] = res.data[key] : ''
					})
				})
			},
			submit() {
				let params = {
					...this.$params,
					...this.form,
				}
				let api = '/master/agency/createAgency'
				if (this.$params.agency_id) api = "/master/agency/editAgency"
				this.$request(api, params).then(res => {
					this.$msg(res.msg)
					this.$navBack(1, 1000)
				})
			},
		}
	}
</script>

<style lang="scss">

</style>